<?php

class AdministratorController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
	$this->view->title = "Subvenio - Администратор";
	$this->view->mode = "Administrator";
    }

    public function indexAction()
    {
        // action body
    }

    public function usersAction()
    {
        // action body
	$this->view->title = "SDM - Администратор/Управление пользователями";
        Zend_Loader::loadClass('Users');
        $users= new Users();
        $this->view->userslist=$users->getlist();
    }

    public function deluserAction()
    {
        // action body
	$this->view->title = "SDM - Администратор/Удаление пользователя";
	
        Zend_Loader::loadClass('Users');
	$users = new Users();
	
	if ($this->_request->isPost())
	{
	    Zend_Loader::loadClass('Zend_Filter_Alpha');
	    $filter = new Zend_Filter_Alpha();
	    
	    $id = (int)$this->_request->getPost('id');
	    $del = $filter->filter($this->_request->getPost('del'));
	    if ($del == 'Yes' && $id > 0)
	    {
		$users->delUser($id);
	    }
	}
        else
	{
	    $id = (int)$this->_request->getParam('id');
	    if ($id > 0)
	    {
		$this->view->user = $users->getUserByid($id);
		if ($this->view->user->id > 0) 
		{
		    return;
		}
	    }
	}
	$this->_redirect($this->view->serverUrl('/Administrator/users'));
    }
}





